package com.haitaoit.chengquan.module.home.activity.maintenance;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.RadioButton;

import com.haitaoit.chengquan.R;
import com.haitaoit.chengquan.base.BaseActivity;
import com.haitaoit.chengquan.module.home.activity.maintenance.adapter.ViewPagerAdapter;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;

public class MaintenanceDetailActivity extends BaseActivity {
    @ViewInject(R.id.view_pager)
    ViewPager view_pager;
    @ViewInject(R.id.detail_show)
    RadioButton detail_show;
    @ViewInject(R.id.introduce_show)
    RadioButton introduce_show;
    @ViewInject(R.id.eva_show)
    RadioButton eva_show;
    @ViewInject(R.id.server_show)
    RadioButton server_show;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView_V(R.layout.activity_maintenance_detail);
        ViewUtils.inject(this);
        setLeftShow(1, R.mipmap.left);
        setRightShow(1, R.mipmap.img51);
        setTitle_V("报价详情");
        backLeft_V();

        ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(this);
        view_pager.setAdapter(viewPagerAdapter);
        view_pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            }

            @Override
            public void onPageSelected(int position) {
                if (position == 0) {
                    detail_show.setChecked(true);
                } else if (position == 1) {
                    introduce_show.setChecked(true);
                } else if (position == 2) {
                    eva_show.setChecked(true);
                } else if (position == 3) {
                    server_show.setChecked(true);
                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        detail_show.setChecked(true);
        view_pager.setCurrentItem(0);

        getIntent().getStringExtra("id");
    }

    @OnClick({R.id.detail_show, R.id.introduce_show, R.id.eva_show, R.id.server_show})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.detail_show:
                view_pager.setCurrentItem(0);
                break;
            case R.id.introduce_show:
                view_pager.setCurrentItem(1);
                break;
            case R.id.eva_show:
                view_pager.setCurrentItem(2);
                break;
            case R.id.server_show:
                view_pager.setCurrentItem(3);
                break;
        }
    }
}
